Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings on CXX/linker flags #211

Closed
wants to merge 1 commit into from

Conversation

AngryLoki
Copy link
Contributor

@AngryLoki AngryLoki commented Jan 2, 2025

  1. When clang is used as system compiler, libraries were built without respecting LDFLAGS. For example, this affected LTO flags, if any (and it only affected clang, not gcc).

  2. Linker flags are registered as CXX flags, which produces warnings during compilation:

clang++: warning: -Wl,-z,noexecstack: 'linker' input unused [-Wunused-command-line-argument]
clang++: warning: -Wl,-znoexecheap: 'linker' input unused [-Wunused-command-line-argument]
clang++: warning: -Wl,-z,relro: 'linker' input unused [-Wunused-command-line-argument]
clang++: warning: -Wl,-z,now: 'linker' input unused [-Wunused-command-line-argument]
  1. Clang does not support -Wtrampolines flag:
warning: unknown warning option '-Wtrampolines' [-Wunknown-warning-option]
  1. No linkers support noexecheap anymore. noexecheap linker flag was a part of PaX patches to GNU ld, which were dropped in 2017. Now ld/ld.lld/ld.gold don't support it and protection of heap is managed by NX bit. Therefore every compiler produces this warning:
ld.lld: warning: unknown -z value: noexecheap

Closes #210.

1) When `clang` is used as system compiler, libraries were built without respecting LDFLAGS. For example, this affected LTO flags, if any (and it only affected clang, not gcc).

2) Linker flags are registered as CXX flags, which produces warnings during compilation:
```
clang++: warning: -Wl,-z,noexecstack: 'linker' input unused [-Wunused-command-line-argument]
clang++: warning: -Wl,-znoexecheap: 'linker' input unused [-Wunused-command-line-argument]
clang++: warning: -Wl,-z,relro: 'linker' input unused [-Wunused-command-line-argument]
clang++: warning: -Wl,-z,now: 'linker' input unused [-Wunused-command-line-argument]
```

3) Clang does not support `-Wtrampolines` flag:
```
warning: unknown warning option '-Wtrampolines' [-Wunknown-warning-option]
```

4) No linkers support `noexecheap` anymore. `noexecheap` linker flag was a part of PaX patches to GNU ld, (which were dropped in 2017)[https://www.gentoo.org/support/news-items/2017-08-19-hardened-sources-removal.html]. Now ld/ld.lld/ld.gold don't support it and protection of heap is managed by NX bit. Therefore every compiler produces this warning:
```
ld.lld: warning: unknown -z value: noexecheap
```

Closes ROCm#210.
@AngryLoki
Copy link
Contributor Author

@gabrpham CI is broken after commit 6f51cd6, as libdrm-dev is not installed.

@dmitrii-galantsev
Copy link
Collaborator

sweet! I'm pulling this into our internal stuff and it should make it upstream soon.
Applying it to https://github.com/ROCm/amdsmi as well.

@dmitrii-galantsev
Copy link
Collaborator

Merged in 4dbc2b6 and ROCm/amdsmi@b256c1b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue]: linker/cxx flags issues
2 participants